import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../obs/CountObsController.dart';
import '../CountController.dart';
import '../TestController.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 4/10/21.
///
/// 可关注公众号：我的大前端生涯   获取最新技术分享
/// 可关注网易云课堂：https://study.163.com/instructor/1021406098.htm
/// 可关注博客：https://blog.csdn.net/zl18603543572
///
///代码清单7-15
///lib/page/count/binding/TestBindingPage.dart
class TestBindingPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: BPage(),
    );
  }
}

class BPage extends GetView<TestController> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(10),
      decoration: BoxDecoration(border: Border.all()), //边框
      child: Row(
        //水平排列文本与按钮
        mainAxisSize: MainAxisSize.min, //包裹子Widget
        children: [
          //数据监听
          GetBuilder<TestController>(
            builder: (TestController controller) {
              return Text("CPage 计数 ${controller.count}");
            },
          ),
          SizedBox(width: 10), //间隔
          ElevatedButton(
            onPressed: () {
              controller.add();
            },
            child: Text("修改值"),
          ),
        ],
      ),
    );
  }
}
